#!/bin/bash

echo "正在配置Gitee SSH连接..."

# 生成SSH密钥
ssh-keygen -t ed25519 -C "$1" -f ~/.ssh/id_ed25519 -N ""

# 启动SSH agent
eval "$(ssh-agent -s)"

# 添加密钥
ssh-add ~/.ssh/id_ed25519

# 创建SSH config
cat >> ~/.ssh/config

Host gitee.com
    HostName gitee.com
    User xfy0708
    IdentityFile ~/.ssh/id_ed25519
    IdentitiesOnly yes


# 设置权限
chmod 600 ~/.ssh/config

# 显示公钥
echo "=== 请将以下公钥添加到Gitee ==="
cat ~/.ssh/id_ed25519.pub
echo "=== 公钥显示结束 ==="

# 测试连接
echo "正在测试连接..."
ssh -T git@gitee.com